package aiyh.utils.sqlUtil.whereUtil.impl;

import aiyh.utils.sqlUtil.whereUtil.InnerWhere;
import aiyh.utils.sqlUtil.whereUtil.InnerWhereOperator;
import aiyh.utils.sqlUtil.whereUtil.Where;

/**
 * @author EBU7-dev1-ayh
 * @date 2021/8/23 0023 22:18
 */


public class InnerPrepWhereImpl implements InnerWhere {
	private final InnerPrepWhereOperatorImpl whereOperator;
	private final PrepWhereImpl prepWhere;

	public InnerPrepWhereOperatorImpl getWhereOperator() {
		return whereOperator;
	}

	{
		this.whereOperator = new InnerPrepWhereOperatorImpl(this);
	}

	public InnerPrepWhereImpl(PrepWhereImpl prepWhere) {
		this.prepWhere = prepWhere;
	}

	@Override
	public InnerWhereOperator whereAnd(String key) {
		this.whereAppend(" and ");
		this.whereAppend(key);
		return this.whereOperator;
	}

	@Override
	public InnerWhereOperator whereOr(String key) {
		this.whereAppend(" or ");
		this.whereAppend(key);
		return this.whereOperator;
	}

	@Override
	public Where endInnerWhere() {
		this.whereAppend(" ) ");
		return this.prepWhere;
	}


	public void whereAppend(Object key) {
		this.prepWhere.whereAppend(key);
	}

	public void addArgs(Object key) {
		this.prepWhere.addArgs(key);
	}
}
